package com.qinggeng.framework.config.mq.impl;

import com.alibaba.fastjson.JSONObject;
import com.qinggeng.framework.config.mq.dto.MessageOrdersAutoShipDTO;
import com.qinggeng.framework.config.mq.handle.MessageHandle;
import com.qinggeng.project.system.service.IOrdersService;
import com.qinggeng.project.system.service.MQSendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AutoShipHandleImpl implements MessageHandle {
    @Autowired
    private IOrdersService ordersService;
    @Autowired
    private MQSendService mqSendService;

    @Override
    public void handle(String msg) {
        log.info("自动发货处理{}"+msg);

        MessageOrdersAutoShipDTO messageOrdersAutoShip = JSONObject.parseObject(msg, MessageOrdersAutoShipDTO.class);
        String ordersNo = messageOrdersAutoShip.getOrdersNo();
        boolean b = ordersService.ordersAutoShip(ordersNo);
        if (!b){
            log.error("AutoShipHandleImpl()={}",ordersNo);
        }

    }
}
